
import {getFinishOrder} from '../services/orders';


export default {
  namespace: 'orders',

  state: {
    editorVisible: false,
    editorType: 'create',
  },

  subscriptions: {
    setup1({dispatch, history}) {
      console.log('setup1', dispatch, history);
    },

    keyEvent({dispatch}) {
      console.log('keyEvent', dispatch);
    },
  },

  effects: {
    *getFinishOrder({payload}, {call, put, select}) {
      console.log('payload', payload);

      const obj = {a:'a', b:'b'};
      console.log(obj['a']);

      const example = yield select((({example}, obj) => example));
      console.log(example);

      const {order} = yield call(getFinishOrder, 'test', 'test2');
      console.log(order);

      yield put({
        type: 'finish',
        test: {
          editorType: 'create',
          editorVisible: true
        },
        xxx:{

        }
      });
    }
  },

  reducers: {
    finish(state, action) {
      console.log('state', state, 'action', action);

      return {...state, orderState: '未完成'};
    },

    ordering(state, action) {
      console.log('state', state, 'action', action);

      return {...state, orderState: '进行中'};
    },
  }
}
